<html>
<head><meta charset="utf-8"><title>bpf targets · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html">bpf targets</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219716327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219716327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219716327">(Dec 12 2020 at 16:40)</a>:</h4>
<p>Hey -- <a href="https://github.com/rust-lang/rust/pull/79608">https://github.com/rust-lang/rust/pull/79608</a> is currently assigned to me (by me :). I don't think until we merge <a href="https://github.com/rust-lang/rfcs/pull/2803">RFC 2803</a> we should be accepting new targets into tier 2 status (and even tier 3 is a bit iffy).</p>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> is there a chance you could provide an update on the timeline for that RFC? Do you need some help from others? Are there other blockers I'm not aware of?</p>
<p>For this particular PR, even demoted to tier 3, I am not familiar enough with BPF to evaluate the target definitions or whether the strategy adopted (asm emission) is the right one. Does anyone have more insight there?</p>



<a name="219726103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219726103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alessandro Decina <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219726103">(Dec 12 2020 at 20:22)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116122">@simulacrum</span>, I'm the author of the PR,  thanks for looking at it! The reason for asm emission is that the BPF target supports a subset of rust, (for example, arguments are only passed in registers, up to a maximum of 5) so it makes sense to push codegen after linking after all dead code has been eliminated</p>



<a name="219726582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219726582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alessandro Decina <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219726582">(Dec 12 2020 at 20:34)</a>:</h4>
<p>There's other reasons too, like older kernels don't allow function calls or loops. When targeting those bpf-linker can turn on more aggressive inlining and unrolling. As they keep adding features and relaxing restrictions in the verifier, I imagine that there will always be a set of hacks needed to target older kernels, and i don't think those would belong in rustc</p>



<a name="219726603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219726603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219726603">(Dec 12 2020 at 20:35)</a>:</h4>
<p>Yeah, that seems reasonable to me - I just don't have enough knowledge to r+ myself :)</p>



<a name="219726914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219726914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alessandro Decina <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219726914">(Dec 12 2020 at 20:42)</a>:</h4>
<p>Hehe sure I still appreciate you looking into it. I'm going to add a bit more context to the PR so maybe others can pitch in</p>



<a name="219805454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219805454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219805454">(Dec 14 2020 at 06:44)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> Working on the policy now. Managed to get it back to the top of my stack for a bit.</p>



<a name="219812328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219812328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219812328">(Dec 14 2020 at 08:38)</a>:</h4>
<p>Also, I'd <em>love</em> to see Rust support for eBPF.</p>



<a name="219812376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219812376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219812376">(Dec 14 2020 at 08:39)</a>:</h4>
<p>I think that'd also be an excellent use case for <a href="https://github.com/rust-lang/rfcs/pull/3028/">https://github.com/rust-lang/rfcs/pull/3028/</a> .</p>



<a name="219812402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219812402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219812402">(Dec 14 2020 at 08:39)</a>:</h4>
<p>I can easily imagine wanting to build and embed a BPF program in another Rust program.</p>



<a name="219813908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219813908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alessandro Decina <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219813908">(Dec 14 2020 at 08:56)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> indeed, the usual workflow is to embed the BPF program in its user-space loader</p>



<a name="219817169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219817169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219817169">(Dec 14 2020 at 09:31)</a>:</h4>
<p>Assuming it doesn't need to be built at runtime, yeah.</p>



<a name="219817688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219817688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219817688">(Dec 14 2020 at 09:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> <a href="https://github.com/rust-lang/rfcs/pull/2803#issuecomment-744312162">https://github.com/rust-lang/rfcs/pull/2803#issuecomment-744312162</a></p>



<a name="219817714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219817714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219817714">(Dec 14 2020 at 09:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> Could you please post an update to <a href="https://github.com/rust-lang/core-team/issues/5">https://github.com/rust-lang/core-team/issues/5</a> (and reopen if appropriate)?</p>



<a name="219842272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/219842272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#219842272">(Dec 14 2020 at 13:43)</a>:</h4>
<p>I will reopen - I want to check in with core on the legal questions asked in the RFC and how we expect teams to resolve those (all conversations with lawyers will almost certainly need to go through core for this purpose, though I'm not clear on whether it'll be necessary in the common case. I found the non-onerous requirements particularly interesting wrt to e.g. apple platforms which are quite expensive to obtain and manage, or other similar platforms where there is basically a requirement to purchase hardware to test for it.</p>



<a name="221313896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/221313896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alessandro Decina <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#221313896">(Dec 31 2020 at 20:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.20meeting.5D.202020-12-31.20.2354818/near/221296782">said</a>:</p>
<blockquote>
<p>(another observation is that its not clear how much utility a bpf target has when there is ebpf...)</p>
</blockquote>
<p>Sorry about the confusion! The targets produce eBPF code. BPF/eBPF in the context of the linux kernel are sadly pretty much used interchangeably. The LLVM target is called BPF but does produce eBPF bytecode, and clang calls it bpf too. That's why I went for bpf-* but happy to rename ebpf-*.</p>



<a name="221314323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/bpf%20targets/near/221314323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alessandro Decina <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/bpf.20targets.html#221314323">(Dec 31 2020 at 20:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.20meeting.5D.202020-12-31.20.2354818/near/221296409">said</a>:</p>
<blockquote>
<p>I think another worry of mine is that it sounds like bpf-linker is (maybe) a tool that they wrote themselves? but I didn't investigate in detail<br>
(nothing against that but seems potentially like something that would vanish)</p>
</blockquote>
<p>I did write it myself, and it's a valid concern of course. A similar conversation happened for the NVPTX target, and it was decided to keep the NVPTX linker out of rust-lang/rustup</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>